<%@page import="com.tiantian.domain.Businessstore"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE>
<html>
<head>
<style type="text/css">
.update {
	font-size: 12px;
	padding-left: 15px;
	color: #0033FF;
}
</style>
<script src="<c:url value='/static/jquery/jquery-1.9.1.min.js'/>"
	type="text/javascript"></script>
<script type="text/javascript"
	src="<c:url value='/static/common/uc_message.js'/>"></script>
<!-- validate -->
<link rel="stylesheet"
	href="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.css'/>" />
<script type="text/javascript"
	src="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.js'/>"></script>
<title>任务任务详情</title>
</head>
<body>
	<div class="col-lg-12">
		<div id="message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h4>
					商家账号信息 <span style="font-size: 14px; padding-left: 30px">状态&nbsp;:
						<c:choose>
							<c:when test="${user.accountStatus==0}">
								<span style="color: #FFB253;">使用中</span>
								<span href="#" class="update business_state"
									accountStatus="${user.accountStatus}"
									businessUserId="${user.businessUserId}">冻结</span>
							</c:when>
							<c:otherwise>
								<span style="color: #FFB253;">已冻结</span>
								<span href="#" class="update business_state"
									accountStatus="${user.accountStatus}"
									businessUserId="${user.businessUserId}">使用</span>
							</c:otherwise>
						</c:choose>
					</span>
				</h4>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal" id="userForm" action="#">
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">商户生账ID&nbsp;:</label>
									<div class="col-sm-7" style="padding-top: 10px;">${user.businessUserId}</div>
									<input type="hidden" id="businessUserId"
										value="${user.businessUserId }">
								</div>

								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">注册时间&nbsp;:</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<fmt:formatDate value="${user.registrationTime}"
											pattern="yyyy-MM-dd" />
									</div>
								</div>




							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">登录账号&nbsp;:</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="userName"
											name="userName" value="${user.userName }" placeholder="登录账号">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码&nbsp;:</label>
									<div class="col-sm-7">
										<input type="password" class="form-control" id="loginPassword"
											name="loginPassword" value="notchange" placeholder="密码">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">联&nbsp;系&nbsp;电&nbsp;话&nbsp;:</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="phone"
											name="phone" value="${user.phone }" placeholder="联系电话">
									</div>
								</div>



							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">Q&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q&nbsp;:</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="qqno" name="qqno"
											value="${user.qqno }" placeholder="QQ">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">微&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;信&nbsp;:</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="wechatNo"
											name="wechatNo" value="${user.wechatNo }" placeholder="微信">
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<div id="store_message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h4>商家店铺信息</h4>
			</div>

			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal">
							<c:forEach items="${stores }" var="store" varStatus="status">
								<%
									if(((Businessstore) pageContext.getAttribute("store")).getBindingStatus() == '2'){
								%>
								<div class="row">
									<h4>
										绑定店铺${status.index+1}<span
											style="font-size: 14px; padding-left: 25px">状态&nbsp;:
											<span style="color: #FFB253;"><%=((Businessstore) pageContext.getAttribute("store"))
						.getBindingStatus() == '2' ? "已绑定" : "未绑定"%></span> <span
											class="update store_state"
											bindingStatus="${store.bindingStatus }"
											storeId="${store.storeId}"><%=((Businessstore) pageContext.getAttribute("store"))
						.getBindingStatus() == '2' ? "解绑" : "绑定"%></span>

										</span>
									</h4>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">店铺名称&nbsp;:</label>
										<div class="col-sm-7" style="padding-top: 10px;">${store.storeName}</div>
									</div>

									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">平&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;台&nbsp;:</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											<c:if test="${store.platformId==1 }">淘宝/天猫</c:if>
											<c:if test="${store.platformId==2 }">京东</c:if>
										</div>
									</div>

									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">网&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;站&nbsp;:</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											<c:if test="${!empty store.storeHomeWebsite }">
												<a href="${store.storeHomeWebsite }" target="_blank">跳转到网站</a>
											</c:if>
										</div>
									</div>

								</div>
								<div class="row">
									<div class="form-group col-sm-10">
										<label class="col-sm-2 control-label">发货地址&nbsp;:</label>
										<div class="col-sm-10" style="padding-top: 10px;">${addresses[status.index] }</div>
									</div>
								</div>
								<%
									}
								%>
							</c:forEach>
						</form>
					</div>
				</div>

			</div>
		</div>
		<div>
			<div class="form-group " style="text-align: center;">
				<button type="button" id="save" class="btn btn-warning btn-sm"
					style="width: 150px">保存</button>
				<button type="button" id="unsave" class="btn btn-default btn-sm"
					style="width: 150px">取消</button>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function($) {
			//保存
			$('#save').click(function() {
				$('#userForm').bootstrapValidator('validate');

			});
			//取消
			$('#unsave').click(function() {
				window.location.href = path + "/user/businessUsersList";
			});

			//商家账号冻结/使用
			$('.business_state').click(function() {
				var _this = this;
				$.ajax({
					type : "post",
					url : path + "/user/editStatus",
					cache : false,
					data : {
						id : $(_this).attr('businessUserId'),
						accountStatus : $(_this).attr('accountStatus'),
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								location.reload(true);
							}
						});

					}
				});
			});

			$('#userForm').bootstrapValidator({
				message : '这个值未通过验证',
				feedbackIcons : {
					valid : 'glyphicon glyphicon-ok',
					invalid : 'glyphicon glyphicon-remove',
					validating : 'glyphicon glyphicon-refresh'
				},
				fields : {
					userName : {
						validators : {
							notEmpty : {
								message : '登录账号是必须的不能为空'
							},
							stringLength : {
								min : 1,
								max : 15,
								message : '登录账号长度在1-15位'
							},
							regexp : {
								regexp : /^[0-9]+$/,
								message : '登录名只能为数字'
							},
						}
					},
					loginPassword : {
						validators : {
							notEmpty : {
								message : '密码是必须的不能为空'
							},
							stringLength : {
								min : 8,
								max : 20,
								message : '登录账号长度在8-20位'
							}
						}
					},
					phone : {
						validators : {
							stringLength : {
								min : 1,
								max : 15,
								message : '联系电话长度在1-15位'
							},
							regexp : {
								regexp : /^[0-9]+$/,
								message : '联系电话只能为数字'
							},
						}
					},
					qqno : {
						validators : {
							stringLength : {
								min : 1,
								max : 20,
								message : 'QQ长度在1-20位'
							}
						}
					},
					wechatNo : {
						validators : {
							stringLength : {
								min : 1,
								max : 20,
								message : '微信长度在1-20位'
							}
						}
					}

				}
			}).on('success.form.bv', function(e) {
				$.blockUI({ message: '加载中...' });
				$.ajax({
					type : "post",
					url : path + "/user/updateBussinessUser",
					cache : false,
					data : {
						businessUserId : $('#businessUserId').val(),
						userName : $('#userName').val(),
						loginPassword : $('#loginPassword').val(),
						accountStatus : $('#accountStatus').val(),
						phone : $('#phone').val(),
						qqno : $('#qqno').val(),
						wechatNo : $('#wechatNo').val(),
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								location.reload(true);
							}else{
								$.unblockUI();
							}
						});

					}
				});
			});

			//商家店铺绑定/解绑
			$('.store_state').click(function() {
				var _this = this;
				$.blockUI({ message: '加载中...' });
				$.ajax({
					type : "post",
					url : path + "/user/editStoreStatus",
					cache : false,
					data : {
						id : $(_this).attr('storeId'),
						status : $(_this).attr('bindingStatus'),
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							
							if (data.success) {
								location.reload(true);
							}else{
								$.unblockUI();
							}
						}, 'store_message');
					}
				});
			});

			//显示消息
			function showmessage(msg, callback, msgId) {
				if (msgId) {
					$('#' + msgId).ucMessage({
						msg : msg,
						callback : callback
					});
				} else {

					$('#message').ucMessage({
						msg : msg,
						callback : callback
					});
				}
			}
		});
	</script>
</body>

</html>